<?php 
require_once '../include/includefiles.php';
require_once '../include/userislogin.php';
?>
<?php 
  $id = $_GET['id'];
  $query = "select * from article where id = ".$id;
  $result = mysql_query($query) or die("查询文章失败");
  $row = mysql_fetch_array($result);
  $title = $row['title'];
  $cont = $row['body'];
  $colid = $row['colid'];
  $id = $row['id'];
  
  if($_POST['id']){
  	$id = $_POST['id'];
  	$title = $_POST['title'];
  	$cont = $_POST['artcontent'];
  	$col = $_POST['col'];
  	$query = " update article set title='".$title."',";
  	$query.= " body='".$cont."',";
  	$query.= " colid=".$col.",";
  	$query.= " uid = ".$_SESSION['uid'];
  	$query.= " where id = ".$id;

  	$result = mysql_query($query) or die("更新文章失败");
  	if($result){
  		alertmsgrtn("更新文章成功","article.php");
  	}
  	
  }
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>修改文章</title>
<style type="text/css">
table{
border-collapse:collapse;
}
body,td,th {
	font-size: 12px;
}
</style>
<script language="JavaScript" type="text/javascript" src="images/jquery-1.7.2.min.js"></script>
<script language="JavaScript" type="text/javascript" src="../editor/xheditor-1.1.14-zh-cn.min.js"></script>
<script>
  $(function(){
	  $.post('actions.php?act=coltree&id=<?php echo $colid;?>',function(data){
    	  $("[name='col']").append(data);
      });

	  });
</script>
</head>

<body>
<form name="form1" method="post" action="">
  <table width="100%">
    <tr bgcolor="#E1E5EE">
      <td height="30" colspan="2" align="center"><strong>修改文章</strong><input name="id" type="hidden" value="<?php echo $id;?>"></td>
    </tr>
    <tr bgcolor="#F7F8F9">
      <td width="22%" height="30" align="right">标题：</td>
      <td width="78%" align="left"><input name="title" type="text" id="title" value=<?php echo $title;?> size="111"></td>
    </tr>
    <tr bgcolor="#F7F8F9">
      <td height="30" align="right">栏目：</td>
      <td height="30" align="left"><select name="col" id="col">
	    
      </select>
      </td>
    </tr>
    <tr bgcolor="#F7F8F9">
      <td height="30" align="right">内容：</td>
      <td height="30" align="left"><textarea name="artcontent" cols="85" rows="30"  
    class="xheditor {html5Upload:false,upLinkUrl:'upload.php',upImgUrl:'upload.php',upFlashUrl:'upload.php',upMediaUrl:'upload.php'}" 
    id="artcontent"><?php echo $cont;?></textarea></td>
    </tr>
    <tr bgcolor="#F7F8F9">
      <td height="30" colspan="2" align="center" valign="middle"><input type="submit" name="Submit" value="确认">
          <input type="reset" name="Submit2" value="重置"></td>
    </tr>
  </table>
</form>
</body>
</html>
